From: Jens Frank Date: Wed, 21 Apr 2004 16:17:49 +0000 (+0000) Subject: Dori's patch: require confirmation for protection/unprotection like it's already... X-Git-Tag: 1.3.0beta1~351 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=ce1a1dbc6b57d2f3b3a9f96e30b69e06d7349bed;p=lhc%2Fweb%2Fwiklou.git Dori's patch: require confirmation for protection/unprotection like it's already done for deletion. --- diff --git a/includes/Article.php b/includes/Article.php index 29349d24be..7f1aacf8a9 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -714,7 +714,7 @@ class Article { function protect( $limit = "sysop" ) { - global $wgUser, $wgOut; + global $wgUser, $wgOut, $wgRequest; if ( ! $wgUser->isSysop() ) { $wgOut->sysopRequired(); @@ -729,17 +729,91 @@ class Article { $wgOut->fatalEror( wfMsg( "badarticleerror" ) ); return; } + + $confirm = $wgRequest->getBool( 'wpConfirmProtect' ) && $wgRequest->wasPosted(); + $reason = $wgRequest->getText( 'wpReasonProtect' ); + + if ( $confirm ) { + $sql = "UPDATE cur SET cur_touched='" . wfTimestampNow() . "'," . "cur_restrictions='{$limit}' WHERE cur_id={$id}"; wfQuery( $sql, DB_WRITE, "Article::protect" ); $log = new LogPage( wfMsg( "protectlogpage" ), wfMsg( "protectlogtext" ) ); if ( $limit === "" ) { - $log->addEntry( wfMsg( "unprotectedarticle", $this->mTitle->getPrefixedText() ), "" ); + $log->addEntry( wfMsg( "unprotectedarticle", $this->mTitle->getPrefixedText() ), $reason ); } else { - $log->addEntry( wfMsg( "protectedarticle", $this->mTitle->getPrefixedText() ), "" ); + $log->addEntry( wfMsg( "protectedarticle", $this->mTitle->getPrefixedText() ), $reason ); } $wgOut->redirect( $this->mTitle->getFullURL() ); + return; + } else { + $reason = htmlspecialchars( wfMsg( "protectreason" ) ); + return $this->confirmProtect( "", $reason, $limit ); + } + } + + # Output protection confirmation dialog + function confirmProtect( $par, $reason, $limit = "sysop" ) + { + global $wgOut; + + wfDebug( "Article::confirmProtect\n" ); + + $sub = htmlspecialchars( $this->mTitle->getPrefixedText() ); + $wgOut->setRobotpolicy( "noindex,nofollow" ); + + $check = ""; + $protcom = ""; + + if ( $limit === "" ) { + $wgOut->setSubtitle( wfMsg( "unprotectsub", $sub ) ); + $wgOut->addWikiText( wfMsg( "confirmunprotecttext" ) ); + $check = htmlspecialchars( wfMsg( "confirmunprotect" ) ); + $protcom = htmlspecialchars( wfMsg( "unprotectcomment" ) ); + $formaction = $this->mTitle->escapeLocalURL( "action=unprotect" . $par ); + } else { + $wgOut->setSubtitle( wfMsg( "protectsub", $sub ) ); + $wgOut->addWikiText( wfMsg( "confirmprotecttext" ) ); + $check = htmlspecialchars( wfMsg( "confirmprotect" ) ); + $protcom = htmlspecialchars( wfMsg( "protectcomment" ) ); + $formaction = $this->mTitle->escapeLocalURL( "action=protect" . $par ); + } + + $confirm = htmlspecialchars( wfMsg( "confirm" ) ); + + $wgOut->addHTML( " +
+ + + + + + + + + + + + + + + + +
+ + + +
 
+ + + +
  + +
+
\n" ); + + $wgOut->returnToMain( false ); } function unprotect() diff --git a/languages/Language.php b/languages/Language.php index 26bc4dbaca..8fc1f40fa1 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1241,6 +1241,15 @@ Last edit was by [[User:$3|$3]] ([[User talk:$3|Talk]]). ", See [[{{ns:4}}:Protected page]] for more information.", "protectedarticle" => "protected [[$1]]", "unprotectedarticle" => "unprotected [[$1]]", +"protectsub" =>"(Protecting \"$1\")", +"confirmprotecttext" => "Do you really want to protect this page?", +"confirmprotect" => "Confirm protection", +"protectcomment" => "Reason for protecting", +"unprotectsub" =>"(Unprotecting \"$1\")", +"confirmunprotecttext" => "Do you really want to unprotect this page?", +"confirmunprotect" => "Confirm unprotection", +"unprotectcomment" => "Reason for unprotecting", +"protectreason" => "(give a reason)", # Undelete "undelete" => "Restore deleted page",